//基础请求类
import { HttpClient, config } from '@/http/HttpClient'
//数据结构
import type { CodeInfoVO, LoginUserDTO, LoginUserVO } from '@/model/LoginModel'

/**
 * 登录模块基础路径
 */
const baseUrl = config.baseURL + '/login'
class LoginHttp extends HttpClient {
  /**
   * 获取验证码
   * @returns 验证码对象
   */
  async getCode(): Promise<CodeInfoVO> {
    const url = baseUrl + '/get-code'
    const result = (await super.get(url)).data
    return result
  }
  /**
   * 登录
   * @returns 验证码对象
   */
  async doLogin(loginInfo: LoginUserDTO): Promise<LoginUserVO> {
    const url = baseUrl + '/do-login'
    const result = (await super.post(url, loginInfo)).data
    return result
  }
}
export default new LoginHttp(config)
